package com.dg11185.nearshop.net.response;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.dg11185.nearshop.net.entity.CommentReply;

/**
 * 
 * @author：Daibo
 * @time：2014-5-16 上午9:51:08
 */
public class GetReplyCommentListResponse {

    public NetStatus status = null;

    public String total = null;

    public List<CommentReply> commentReplies = null;

    public GetReplyCommentListResponse() {
        commentReplies = new ArrayList<CommentReply>();
    }

    public void parseJson(String response) {
        try {
            JSONObject jsonObject = new JSONObject(response);
            total = jsonObject.optString("total");
            status = NetStatus.getStatus(jsonObject.optString("status"));

            if (!jsonObject.isNull("replyCommentList")) {
                JSONArray replyArray = jsonObject.optJSONArray("replyCommentList");

                for (int a = 0; a < replyArray.length(); a++) {
                    CommentReply reply = new CommentReply();
                    reply.parseEntity(replyArray.getJSONObject(a));
                    commentReplies.add(reply);
                }
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
}
